﻿using System;
using System.Text;

namespace HigLabo.Net.WindowsLive
{
    /// <summary>
    /// 
    /// </summary>
    public class CopyFileCommand : WindowsLiveCommand
    {
        /// <summary>
        /// 
        /// </summary>
        public String TargetFolderID { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public override HttpMethodName MethodName
        {
            get
            {
                return HttpMethodName.Copy;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="path"></param>
        /// <param name="targetFolderID"></param>
        public CopyFileCommand(String path, String targetFolderID)
            : base(path)
        {
            TargetFolderID = targetFolderID;
            this.ParameterCheck();
            this.ContentType = "application/json";
        }
        /// <summary>
        /// 
        /// </summary>
        private void ParameterCheck()
        {
            if (HttpClient.IsNullOrWhiteSpace(TargetFolderID))
                throw new ArgumentNullException("Parameter is error");
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        protected override byte[] SetData()
        {
            this.ParameterCheck();
            StringBuilder s = new StringBuilder();
            s.AppendLine("{");
            s.AppendFormat("destination: \"{0}\"", TargetFolderID);
            s.Append("\r\n}");

            return Encoding.UTF8.GetBytes(s.ToString());
            
        }
    }
}
